home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
STANDALO
/
DB6
/
SHIFTKEY.C
< prev
Wrap
C/C++ Source or Header
|
1990-10-26
|
3KB
|
97 lines
/****************************************************/
/* */
/* XFCN for MichrophoneII to tell whether the */
/* user has the Shift key pressed. */
/* Written by Don Bachner ⌐ October 1990 */
/* Free to all except for resale */
/* */
/****************************************************/
#include "HyperXCmd.h"
#include <string.h>
/*********************************** GlobalDefines ***********************/
#define MIN_SLEEP 0L
#define NIL_MOUSE_REGION 0L
#define WNE_TRAP_NUM 0x60
#define UNIMPL_TRAP_NUM 0x9F
/*********************************** Prototypes ************************/
pascal void main (XCmdBlockPtr);
Handle CopyStrToHand ( char*);
/******************************** main *********/
pascal void
main( XCmdBlockPtr paramPtr )
{
Boolean eventHappened,WNEImplemented;
EventRecord theEvent;
short i;
WNEImplemented= (NGetTrapAddress( WNE_TRAP_NUM,ToolTrap )!=
NGetTrapAddress(UNIMPL_TRAP_NUM, ToolTrap ) );
if( WNEImplemented )
eventHappened=WaitNextEvent( everyEvent,&theEvent,MIN_SLEEP,NIL_MOUSE_REGION );
else
{
SystemTask();
eventHappened=GetNextEvent( everyEvent, &theEvent );
}
/*Since MichII traps for mousedowns and looks to the modifiers field for the */
/*command or option key, this will flush those events(mouseDown/KeyDown). */
/*Thus, using mouseUp (which is just sitting there minding it's own business in */
/*the event que-very lonely) is the way to go!! */
if (eventHappened)
{
switch ( theEvent.what )
{
case keyDown: /*These are here for no good reason, really!*/
case autoKey:
if( (theEvent.modifiers & shiftKey ) !=0)
paramPtr->returnValue = (Handle)CopyStrToHand("true" );
break;
case mouseUp: /*This will always be trapped*/
if( (theEvent.modifiers & shiftKey ) !=0)
paramPtr->returnValue = (Handle)CopyStrToHand("true" );
else
paramPtr->returnValue = (Handle)CopyStrToHand("false" );
break;
default:/*Not really needed, but just in case you really need 'false'*/
paramPtr->returnValue = (Handle)CopyStrToHand("false" );
break;
}
}
return;
}
/*********************************** CopyStrToHand ***********************/
Handle
CopyStrToHand(char *str)
{
Handle resultHandle;
resultHandle= NewHandle((long)strlen(str) +1); /*Add one for 0 termination*/
strcpy((char*)(*resultHandle),str);
return(resultHandle);
}
/****END ShiftKey() October 23, 1990****/